import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

import etxt2db.api.ClassificationEvaluator;
import etxt2db.api.ClassificationExecutor;
import etxt2db.api.ClassificationModel;
import etxt2db.api.ClassificationModelCreator;
import etxt2db.features.CharacterFeatureClassifier;
import etxt2db.features.CharacterTypeFeatureClassifier;
import etxt2db.features.DictionaryFeatureClassifier;
import etxt2db.features.EditableTokenFE;
import etxt2db.features.PatternFeatureClassifier;
import etxt2db.features.SizeFeatureClassifier;
import etxt2db.features.ValueCaseInsensitiveFeatureClassifier;
import etxt2db.features.ValueCaseSensitiveFeatureClassifier;
import etxt2db.serialization.ClassificationModelSerializer;


public class TestePerguntasCinema {
public static void main(String[] args) throws IOException, ParseException{
		
		//List<CharacterFeatureClassifier> features = new ArrayList<CharacterFeatureClassifier>();
		//features.add(new ValueCaseInsensitiveFeatureClassifier());
		//features.add(new PatternFeatureClassifier());
		//features.add(new CharacterTypeFeatureClassifier());
		//features.add(new DictionaryFeatureClassifier("./resources/Mario/nome.txt"));
		//features.add(new SizeFeatureClassifier());
		//EditableTokenFE featureExtractor = new EditableTokenFE(features);
		
		ClassificationModelCreator trainer = new ClassificationModelCreator();
		
		trainer.setDocPerFile(false);
		
		List<String> types = new ArrayList<String>();
		//types.add("movie");
		types.add("LOC");
		types.add("PER");
		types.add("ORG");
		
		File trainingFile = new File("C:\\Users\\Goncalo\\Desktop\\annotated_1500.txt");
		
		
		//ClassificationModel an = trainer.trainMachineLearningModel(trainingFile, ClassificationModelCreator.MLTechnique.SVM, types);
		
		ClassificationModelSerializer serial = new ClassificationModelSerializer();
	//	serial.serializeClassificationModel(an, "C:\\Users\\Goncalo\\Desktop\\annotated_1500.model");
		ClassificationModel an = serial.deserializeClassificationModel("C:\\Users\\Goncalo\\Desktop\\annotated_1500.model");
		
		ClassificationExecutor tester = new ClassificationExecutor();
		tester.setDocPerFile(false);
		
		//System.out.println(tester.getClassifiedString(testingFile, an, types));
		
		//ClassificationEvaluator eval = new ClassificationEvaluator();
		//eval.setDocPerFile(false);
		
		//File annotatedCorpus = new File("./resources/Mario/50_perguntas_etiquetadas_correctamente.txt");
		
		//eval.printEvaluationReport(annotatedCorpus, an, types);
		
		System.out.println(tester.getClassifiedString("How did serfdom develop in and then leave Russia ?", an, types));
		System.out.println(tester.getClassifiedSegments("How did serfdom develop in and then leave Russia ?", an, types));
	}
}
